package com.ihome.android.http;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Build;

import com.ihome.android.EAApp;
import com.ihome.android.common.ConfigUtil;
import com.ihome.android.http.upload.UploadUtil;
import com.ihome.android.util.AppUtils;
import com.ihome.android.util.SPMgr;
import com.ihome.android.util.TripleDesUtil;
import com.ihome.android.util.Util;
import com.ihome.android.util.exception.ITVException;
import com.ihome.android.util.log.LogUtil;

/**
 * 各类网络请求接口
 * 
 * @author Emerson
 * 
 */
public class HttpActions {
	public final String			TAG		= HttpActions.class.getSimpleName();
	public Http					https;
	public List<NameValuePair>	list;
	public Context				context;
	public static final String	DESKey	= "YUE_XUE_TANG_3DES_YXTANG";

	public HttpActions(Context context) {
		this.context = context;
		https = Http.getInstance(context);
		list = new ArrayList<NameValuePair>();
	}

	//----------------------------start---2015-08-04 添加悦学堂的请求方法，实现des3加密解密的方法-------------------
	
	public String requestHomePage(String areaNo) throws ITVException{
		list.clear();
		list.add(new BasicNameValuePair(HttpKeys.KEY_METHOD, "requestHomePage"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_TIMESTAMP_LOWER, "" + System.currentTimeMillis()));
		list.add(new BasicNameValuePair(HttpKeys.KEY_AREANO, SPMgr.getInstance(context).getElement(HttpKeys.KEY_AREANO, "320000")));
		return TripleDesUtil.decrypt(HttpKeys.KEY_DES3, https.get(list));
	}
	
	//----------------------------end-----2015-08-04 添加悦学堂的请求方法，实现des3加密解密的方法-------------------

	
	
	
	
	
	
	// ----------------------------------2013-07-09---------------------------------------------
	/**
	 * 2.1 用户注册接口 若没有则注册应用商城账号，设置应用商城登录密码、支付密码，登录密码自动加密保存在机顶盒中。
	 */
	public String register(String appUserName, String pwd) throws ITVException {
		list.clear();
		list.add(new BasicNameValuePair(HttpKeys.KEY_METHOD, "user.register"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_AREANO, ""));
		list.add(new BasicNameValuePair(HttpKeys.KEY_AUTHENTICATOR, createRegisterAuth(appUserName, pwd)));
		list.add(new BasicNameValuePair(HttpKeys.KEY_USERAPPGROUP, ConfigUtil.USERAPPGROUP));
		list.add(new BasicNameValuePair(HttpKeys.KEY_OTT_CLIENTID, Util.getOTTClientID(context))); // Util.getOTTClientID(context)
		list.add(new BasicNameValuePair(HttpKeys.KEY_TIMESTAMP_LOWER, "" + System.currentTimeMillis()));
		list.add(new BasicNameValuePair(HttpKeys.KEY_MAC, Util.getWlanMacAddr() + "|" + Util.getEthMacAddr()));
		list.add(new BasicNameValuePair(HttpKeys.KEY_STBID, Build.ID));
		list.add(new BasicNameValuePair(HttpKeys.KEY_APPKEY, "appkey"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_VERSION, "1.0"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_FORMAT, "json"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SIG, "sig"));
		return https.get(list);
	}

	/**
	 * Authenticator=3DES(random +“$”+ transactionID + “$”+ APPUserName+
	 * ”$”+loginPassword +”$”+ iTVUserID)
	 * 
	 * @param appUserName
	 * @param loginPwd
	 * @return
	 */
	public String createRegisterAuth(String appUserName, String pwd) {
		String auth = "";

		List<String> authList = new ArrayList<String>();
		authList.add(Util.getHexRandom());
		authList.add(Util.createTransactionID());
		authList.add(appUserName);
		authList.add(pwd);
		authList.add("");

		String str = Util.spliceAuthUrl(authList, false);
		LogUtil.v(TAG, "RegisterAuth strBefore = " + str);
		auth = TripleDesUtil.encode(DESKey, str);
		LogUtil.v(TAG, "RegisterAuth Auth = " + auth);
		return auth;
	}

	/**
	 * 2.2 用户注册账号唯一性校验接口
	 * 
	 * @return
	 * @throws ITVException
	 */
	public String checkAppUserName(String appUserName) throws ITVException {
		list.clear();
		list.add(new BasicNameValuePair(HttpKeys.KEY_METHOD, "user.checkAppUserName"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_APPUSERNAME, appUserName));
		list.add(new BasicNameValuePair(HttpKeys.KEY_TRANSACTIONID, Util.createTransactionID()));
		list.add(new BasicNameValuePair(HttpKeys.KEY_TIMESTAMP_LOWER, "" + System.currentTimeMillis()));
		list.add(new BasicNameValuePair(HttpKeys.KEY_MAC, Util.getMac()));
		list.add(new BasicNameValuePair(HttpKeys.KEY_STBID, Build.ID));
		list.add(new BasicNameValuePair(HttpKeys.KEY_APPKEY, "appkey"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_VERSION, "1.0"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_FORMAT, "json"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SIG, "sig"));
		return https.get(list);
	}

	/**
	 * 2.8 用户登录认证接口 用户登录应用商城客户端时，应用商城客户端向增值业务管理平台发起认证请求。
	 * 
	 * @param pwd
	 *            应用商城登陆密码
	 * @param operateFlag
	 *            0：正常登录 1：应用商城账户与IPTV账号重新绑定
	 * @return
	 * @throws ITVException
	 */
	public String loginReq(String appUserName, String pwd, int operateFlag) throws ITVException {
		list.clear();
		list.add(new BasicNameValuePair(HttpKeys.KEY_METHOD, "user.login"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_APPUSERNAME, appUserName));
		list.add(new BasicNameValuePair(HttpKeys.KEY_USERAPPGROUP, ConfigUtil.USERAPPGROUP));
		list.add(new BasicNameValuePair(HttpKeys.KEY_OTT_CLIENTID, Util.getOTTClientID(context)));
		list.add(new BasicNameValuePair(HttpKeys.KEY_TIMESTAMP_LOWER, "" + System.currentTimeMillis()));
		list.add(new BasicNameValuePair(HttpKeys.KEY_AUTHENTICATOR, createLoginAuth(appUserName, pwd)));
		list.add(new BasicNameValuePair(HttpKeys.KEY_OPERATEFLAG, "" + operateFlag));
		list.add(new BasicNameValuePair(HttpKeys.KEY_STBID, Build.ID));
		list.add(new BasicNameValuePair(HttpKeys.KEY_MAC, Util.getMac()));
		list.add(new BasicNameValuePair(HttpKeys.KEY_APPKEY, "appkey"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_VERSION, "1.0"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_FORMAT, "json"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SIG, "sig"));
		return https.get(list);
	}

	/**
	 * 6. Authenticator=3DES(Random+“$”+APPUserName +”$” + iTVUserID +“$”+
	 * transactionID)
	 * 
	 * @param appUserName
	 * @param pwd
	 * @return
	 */
	public String createLoginAuth(String appUserName, String pwd) {
		String auth = "";

		List<String> authList = new ArrayList<String>();
		authList.add(Util.getHexRandom());
		authList.add(appUserName);
		authList.add("");
		authList.add(Util.createTransactionID());

		String str = Util.spliceAuthUrl(authList, false);
		LogUtil.v(TAG, "LoginAuth strBefore = " + str);

		// 获取MD5加密的登录密码，并截取前24位作为3DES加密密钥
		String key = DESKey;
		LogUtil.v(TAG, "LoginAuth key = " + key + "; key.length = " + key.length());
		if (key.length() > 24) {
			key = key.substring(0, 24);
		}
		LogUtil.v(TAG, "LoginAuth key = " + key + "; key.length = " + key.length());
		auth = TripleDesUtil.encode(key, str);
		LogUtil.v(TAG, "LoginAuth Auth = " + auth);
		return auth;
	}

	/**
	 * 2.9 用户登出接口 应用商城客户端退出时，需要向应用商城管理平台发送退出请求，
	 * 应用商城管理平台通过sessionkey需要记录用户的退出信息，在线时长等信息。
	 * 
	 * @return
	 * @throws ITVException
	 */
	public String logout() throws ITVException {
		list.clear();
		list.add(new BasicNameValuePair(HttpKeys.KEY_METHOD, "user.logout"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_TIMESTAMP_LOWER, "" + System.currentTimeMillis()));
		list.add(new BasicNameValuePair(HttpKeys.KEY_APPKEY, "appkey"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_VERSION, "1.0"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_FORMAT, "json"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SIG, "sig"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SESSIONKEY, ConfigUtil.SessionKey));
		return https.get(list);
	}

	/**
	 * 2.10 获取海报接口 该接口用于应用商城客户端向应用商城管理平台获取海报。
	 * 
	 * @return
	 * @throws ITVException
	 */
	public String getPoster() throws ITVException {
		list.clear();
		list.add(new BasicNameValuePair(HttpKeys.KEY_METHOD, "client.getPoster"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_TIMESTAMP_LOWER, "" + System.currentTimeMillis()));
		list.add(new BasicNameValuePair(HttpKeys.KEY_APPKEY, "appkey"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_VERSION, "1.0"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_FORMAT, "json"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SIG, "sig"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_OPTION, "1"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SESSIONKEY, ConfigUtil.SessionKey));
		return https.get(list);
	}

	/**
	 * 2.11 获取分类接口(所有或推荐展示) 该接口用于应用商城客户端向应用商城管理平台获取所有分类或者展示分类。
	 * 
	 * @return
	 * @throws ITVException
	 */
	public String getCategory(int recommflag, int parentId) throws ITVException {
		list.clear();
		list.add(new BasicNameValuePair(HttpKeys.KEY_METHOD, "app.getCategory"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_TIMESTAMP_LOWER, "" + System.currentTimeMillis()));
		list.add(new BasicNameValuePair(HttpKeys.KEY_APPKEY, "appkey"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_VERSION, "1.0"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_FORMAT, "json"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SIG, "sig"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SESSIONKEY, ConfigUtil.SessionKey));
		list.add(new BasicNameValuePair(HttpKeys.KEY_RECOMMFLAG, "" + recommflag));
		list.add(new BasicNameValuePair(HttpKeys.KEY_PARENTID, "" + parentId));
		return https.get(list);
	}

	/**
	 * 2.12 根据分类获取应用接口(所有或推荐) 该接口用于应用商城客户端根据分类向应用商城管理平台获取应用。
	 * 
	 * @return
	 * @throws ITVException
	 */
	public String getCategoryApp(int cid, int startIndex, int sort, int charge, int maxNum) throws ITVException {
		list.clear();
		list.add(new BasicNameValuePair(HttpKeys.KEY_METHOD, "client.getCategoryApp"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_TIMESTAMP_LOWER, "" + System.currentTimeMillis()));
		list.add(new BasicNameValuePair(HttpKeys.KEY_APPKEY, "appkey"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_VERSION, "1.0"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_FORMAT, "json"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SIG, "sig"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SESSIONKEY, ConfigUtil.SessionKey));
		list.add(new BasicNameValuePair(HttpKeys.KEY_CID, "" + cid));
		list.add(new BasicNameValuePair(HttpKeys.KEY_STARTINDEX, "" + startIndex));
		list.add(new BasicNameValuePair(HttpKeys.KEY_MAXNUM, "" + maxNum));
		list.add(new BasicNameValuePair(HttpKeys.KEY_RECOMMFLAG, "" + 0));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SORT, "" + sort));
		list.add(new BasicNameValuePair(HttpKeys.KEY_CHARGE, "" + charge));
		list.add(new BasicNameValuePair(HttpKeys.KEY_CACHEKEY, EAApp.getApp().cacheKey));
		return https.get(list);
	}

	/**
	 * 2.6 获取应用签名接口 用户在未登录的情况下，根据应用的包名向应用商城管理平台获取应用的签名。
	 * 
	 * @return
	 * @throws ITVException
	 */
	public String getAPKSignature(String packagename) throws ITVException {
		list.clear();
		list.add(new BasicNameValuePair(HttpKeys.KEY_METHOD, "user.getAPKSignature"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_TIMESTAMP_LOWER, "" + System.currentTimeMillis()));
		list.add(new BasicNameValuePair(HttpKeys.KEY_APPKEY, "appkey"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_VERSION, "1.0"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_FORMAT, "json"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SIG, "sig"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SESSIONKEY, ConfigUtil.SessionKey));
		list.add(new BasicNameValuePair(HttpKeys.KEY_PACKAGENAME, packagename));
		list.add(new BasicNameValuePair(HttpKeys.KEY_USERTOKEN_LOWER, "07194099690533688497770115093520"));
		return https.get(list);
	}

	/**
	 * 2.13 获取应用签名证书接口（应用合法性校验） 应用商城内的业务鉴权时需要调用此接口，第三方应用启动时，也需要调用此接口校验应用的合法性；
	 * 备注：应用商城需要保存一份应用的签名信息。
	 * 
	 * @return
	 * @throws ITVException
	 */
	public String getAPKCertificate(String packagename) throws ITVException {
		list.clear();
		list.add(new BasicNameValuePair(HttpKeys.KEY_METHOD, "user.getAPKCertificate"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_APPUSERNAME, Util.getOTTUserName(context)));
		list.add(new BasicNameValuePair(HttpKeys.KEY_APPMARKETID, "" + ConfigUtil.APPMARKETID));
		list.add(new BasicNameValuePair(HttpKeys.KEY_TIMESTAMP_LOWER, "" + System.currentTimeMillis()));
		list.add(new BasicNameValuePair(HttpKeys.KEY_TRANSACTIONID, Util.createTransactionID()));
		list.add(new BasicNameValuePair(HttpKeys.KEY_PACKAGENAME, packagename));
		list.add(new BasicNameValuePair(HttpKeys.KEY_STBID, Build.ID));
		list.add(new BasicNameValuePair(HttpKeys.KEY_MAC, Util.getMac()));
		list.add(new BasicNameValuePair(HttpKeys.KEY_APPKEY, "appkey"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_VERSION, "1.0"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_FORMAT, "json"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SIG, "sig"));
		return https.get(list);
	}

	/**
	 * 2.17 应用鉴权接口 <br>
	 * 用户登录应用商城客户端后，浏览和下载应用时，由应用商城客户端向应用商城平台发起业务鉴权请求，<br>
	 * 判断用户是否可以使用当前应用，完成应用的业务鉴权。<br>
	 * 
	 * @param appID
	 *            应用ID
	 * @return
	 * @throws ITVException
	 */
	public String getAppAuth(String appID) throws ITVException {
		list.clear();
		list.add(new BasicNameValuePair(HttpKeys.KEY_METHOD, "app.getAuth"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_APPUSERNAME, Util.getOTTUserName(context)));
		list.add(new BasicNameValuePair(HttpKeys.KEY_TIMESTAMP_LOWER, "" + System.currentTimeMillis()));
		list.add(new BasicNameValuePair(HttpKeys.KEY_TRANSACTIONID, Util.createTransactionID()));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SESSIONKEY, ConfigUtil.SessionKey));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SPID, ConfigUtil.IPTV_SPID));
		list.add(new BasicNameValuePair(HttpKeys.KEY_APPID, appID));
		list.add(new BasicNameValuePair(HttpKeys.KEY_STBID, Build.ID));
		list.add(new BasicNameValuePair(HttpKeys.KEY_MAC, Util.getMac()));
		list.add(new BasicNameValuePair(HttpKeys.KEY_OTT_CLIENTID, Util.getOTTClientID(context)));
		list.add(new BasicNameValuePair(HttpKeys.KEY_APPKEY, "appkey"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_VERSION, "1.0"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_FORMAT, "json"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SIG, "sig"));
		return https.get(list);
	}

	/**
	 * 2.18 获取应用详情接口 用户选择某一应用图标可进入该软件的详情
	 * 
	 * @return
	 * @throws ITVException
	 */
	public String getAppInfo(int appId, String form) throws ITVException {
		list.clear();
		list.add(new BasicNameValuePair(HttpKeys.KEY_METHOD, "app.getInfo"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_TIMESTAMP_LOWER, "" + System.currentTimeMillis()));
		list.add(new BasicNameValuePair(HttpKeys.KEY_APPUSERNAME, Util.getOTTUserName(context)));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SESSIONKEY, ConfigUtil.SessionKey));
		list.add(new BasicNameValuePair(HttpKeys.KEY_APPID, "" + appId));
		list.add(new BasicNameValuePair(HttpKeys.KEY_FROM, form));
		list.add(new BasicNameValuePair(HttpKeys.KEY_TRANSACTIONID, Util.createTransactionID()));
		list.add(new BasicNameValuePair(HttpKeys.KEY_TOKENTYPE, "0"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_STBID, Build.ID));
		list.add(new BasicNameValuePair(HttpKeys.KEY_MAC, Util.getMac()));
		list.add(new BasicNameValuePair(HttpKeys.KEY_APPKEY, "appkey"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_VERSION, "1.0"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_FORMAT, "json"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SIG, "sig"));
		return https.get(list);
	}

	/**
	 * 2.19 应用收藏接口 用户进入某一应用详情可收藏该应用，收藏指数会相应增加，每一用户只能收藏一次同一应用。
	 * 
	 * @param flag
	 *            操作标志位。0：收藏，1：取消收藏。
	 * 
	 * @return
	 * @throws ITVException
	 */
	public String appCollect(String appId, int flag) throws ITVException {
		list.clear();
		list.add(new BasicNameValuePair(HttpKeys.KEY_METHOD, "collect.app"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_TIMESTAMP_LOWER, "" + System.currentTimeMillis()));
		list.add(new BasicNameValuePair(HttpKeys.KEY_APPKEY, "appkey"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_VERSION, "1.0"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_FORMAT, "json"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SIG, "sig"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SESSIONKEY, ConfigUtil.SessionKey));
		list.add(new BasicNameValuePair(HttpKeys.KEY_APPID, appId));
		list.add(new BasicNameValuePair(HttpKeys.KEY_FLAG, "" + flag));
		return https.get(list);
	}

	/**
	 * 2.20 应用评分接口 用户在下载并使用某一应用后可对该应用进行评分，系统会对应用评分进行汇总。
	 * 
	 * @return
	 * @throws ITVException
	 */
	public String appEvaluate(String appId, String appRate, String content) throws ITVException {
		list.clear();
		list.add(new BasicNameValuePair(HttpKeys.KEY_METHOD, "evaluate.app"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_TIMESTAMP_LOWER, "" + System.currentTimeMillis()));
		list.add(new BasicNameValuePair(HttpKeys.KEY_APPKEY, "appkey"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_VERSION, "1.0"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_FORMAT, "json"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SIG, "sig"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SESSIONKEY, ConfigUtil.SessionKey));
		list.add(new BasicNameValuePair(HttpKeys.KEY_APPID, appId));
		list.add(new BasicNameValuePair(HttpKeys.KEY_APPRATE, appRate));
		list.add(new BasicNameValuePair(HttpKeys.KEY_CONTENT, content));
		return https.get(list);
	}

	/**
	 * 2.21 应用下载接口 用户在下载前，先调用接口获取应用的下载URL。用户下载完成后,需要调用此接口,返回用户下载完成信息。
	 * 
	 * @param appType
	 *            应用类型：0，标示正常应用；1，标示测试应用
	 * @param opflag
	 *            操作类型：0，获取URL；1，下载完成
	 * @return
	 * @throws ITVException
	 */
	public String downApp(int appType, String appId, int opflag) throws ITVException {
		list.clear();
		list.add(new BasicNameValuePair(HttpKeys.KEY_METHOD, "trade.downApp"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_TIMESTAMP_LOWER, "" + System.currentTimeMillis()));
		list.add(new BasicNameValuePair(HttpKeys.KEY_APPKEY, "appkey"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_VERSION, "1.0"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_FORMAT, "json"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SIG, "sig"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SESSIONKEY, ConfigUtil.SessionKey));
		list.add(new BasicNameValuePair(HttpKeys.KEY_APPID, appId));
		list.add(new BasicNameValuePair(HttpKeys.KEY_OPFLAG, "" + opflag));
		list.add(new BasicNameValuePair(HttpKeys.KEY_APPTYPE, "" + appType));
		return https.get(list);
	}

	/**
	 * 2.22 获取关联应用接口 用户打开应用详情页面时，需要获取关联应用。
	 * 
	 * @return
	 * @throws ITVException
	 */
	public String getRelativeApp(int appId, int startIndex, int maxNum) throws ITVException {
		list.clear();
		list.add(new BasicNameValuePair(HttpKeys.KEY_METHOD, "app.getRelativeApp"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_TIMESTAMP_LOWER, "" + System.currentTimeMillis()));
		list.add(new BasicNameValuePair(HttpKeys.KEY_APPKEY, "appkey"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_VERSION, "1.0"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_FORMAT, "json"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SIG, "sig"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SESSIONKEY, ConfigUtil.SessionKey));
		list.add(new BasicNameValuePair(HttpKeys.KEY_APPID, "" + appId));
		list.add(new BasicNameValuePair(HttpKeys.KEY_STARTINDEX, "" + startIndex));
		list.add(new BasicNameValuePair(HttpKeys.KEY_MAXNUM, "" + maxNum));
		return https.get(list);
	}

	/**
	 * 2.23 获取用户收藏应用接口 获取用户收藏的应用列表，分页返回数据。
	 * 
	 * @return
	 * @throws ITVException
	 */
	public String getFavouriteApp(int startIndex, int maxNum) throws ITVException {
		list.clear();
		list.add(new BasicNameValuePair(HttpKeys.KEY_METHOD, "user.getFavouriteApp"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_TIMESTAMP_LOWER, "" + System.currentTimeMillis()));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SESSIONKEY, ConfigUtil.SessionKey));
		list.add(new BasicNameValuePair(HttpKeys.KEY_STARTINDEX, "" + startIndex));
		list.add(new BasicNameValuePair(HttpKeys.KEY_MAXNUM, "" + maxNum));
		list.add(new BasicNameValuePair(HttpKeys.KEY_APPKEY, "appkey"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_VERSION, "1.0"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_FORMAT, "json"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SIG, "sig"));
		return https.get(list);
	}

	/**
	 * 2.24 获取用户下载应用接口 获取用户下载的应用列表，返回所有数据。
	 * 
	 * @return
	 * @throws ITVException
	 */
	public String getDownloadApp() throws ITVException {
		list.clear();
		list.add(new BasicNameValuePair(HttpKeys.KEY_METHOD, "user.getDownloadApp"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_TIMESTAMP_LOWER, "" + System.currentTimeMillis()));
		list.add(new BasicNameValuePair(HttpKeys.KEY_APPKEY, "appkey"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_VERSION, "1.0"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_FORMAT, "json"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SIG, "sig"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SESSIONKEY, ConfigUtil.SessionKey));
		return https.get(list);
	}

	/**
	 * 2.25 获取应用是否需要更新接口 获取应用版本是否需要更新,应用版本更新通知。
	 * 
	 * @return
	 * @throws ITVException
	 */
	public String appIsUpdate(String appList) throws ITVException {
		list.clear();
		list.add(new BasicNameValuePair(HttpKeys.KEY_METHOD, "app.IsUpdate"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_TIMESTAMP_LOWER, "" + System.currentTimeMillis()));
		list.add(new BasicNameValuePair(HttpKeys.KEY_APPKEY, "appkey"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_VERSION, "1.0"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_FORMAT, "json"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SIG, "sig"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SESSIONKEY, ConfigUtil.SessionKey));
		list.add(new BasicNameValuePair(HttpKeys.KEY_APPLIST, appList));
		return https.get(list);
	}

	/**
	 * 2.26 获取用户信息接口 获取客户端基本信息和个性化信息。
	 * 
	 * @return
	 * @throws ITVException
	 */
	public String getUserInfo() throws ITVException {
		list.clear();
		list.add(new BasicNameValuePair(HttpKeys.KEY_METHOD, "user.getInfo"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_TIMESTAMP_LOWER, "" + System.currentTimeMillis()));
		list.add(new BasicNameValuePair(HttpKeys.KEY_APPKEY, "appkey"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_VERSION, "1.0"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_FORMAT, "json"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SIG, "sig"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_APPUSERNAME, Util.getOTTUserName(context)));
		return https.get(list);
	}

	/**
	 * 2.27 更新用户信息接口 更新客户端个性化信息
	 * 
	 * @return
	 * @throws ITVException
	 */
	public String updateUserInfo(String nickname, String realName, String sex, String birthday, String email) throws ITVException {
		list.clear();
		list.add(new BasicNameValuePair(HttpKeys.KEY_METHOD, "user.updateInfo"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_TIMESTAMP_LOWER, "" + System.currentTimeMillis()));
		list.add(new BasicNameValuePair(HttpKeys.KEY_APPUSERNAME, Util.getOTTUserName(context)));
		list.add(new BasicNameValuePair(HttpKeys.KEY_APPKEY, "appkey"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_VERSION, "1.0"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_FORMAT, "json"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SIG, "sig"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_NICKNAME, nickname));
		list.add(new BasicNameValuePair(HttpKeys.KEY_REALNAME, realName));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SEX, sex));
		list.add(new BasicNameValuePair(HttpKeys.KEY_BIRTHDAY, birthday));
		list.add(new BasicNameValuePair(HttpKeys.KEY_EMAIL, email));
		return https.get(list);
	}

	/**
	 * 2.28 应用搜索接口 用户根据关键字模糊查询所有应用，在应用名称和应用标签中进行搜索。
	 * 
	 * @return
	 * @throws ITVException
	 */
	public String searchApp(String startIndex, String maxNum, String keyword, int sort, int charge, String pkgName) throws ITVException {
		list.clear();
		list.add(new BasicNameValuePair(HttpKeys.KEY_METHOD, "app.search"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_TIMESTAMP_LOWER, "" + System.currentTimeMillis()));
		list.add(new BasicNameValuePair(HttpKeys.KEY_APPKEY, "appkey"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_VERSION, "1.0"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_FORMAT, "json"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SIG, "sig"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SESSIONKEY, ConfigUtil.SessionKey));
		list.add(new BasicNameValuePair(HttpKeys.KEY_STARTINDEX, startIndex));
		list.add(new BasicNameValuePair(HttpKeys.KEY_MAXNUM, maxNum));
		list.add(new BasicNameValuePair(HttpKeys.KEY_PACKAGENAME, pkgName));
		try {
			list.add(new BasicNameValuePair(HttpKeys.KEY_KEYWORD, URLEncoder.encode(URLEncoder.encode(keyword, "UTF-8"), "UTF-8")));
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}
		list.add(new BasicNameValuePair(HttpKeys.KEY_SORT, "" + sort));
		list.add(new BasicNameValuePair(HttpKeys.KEY_CHARGE, "" + charge));
		return https.get(list);
	}

	/**
	 * 2.29 同步接口服务器负载状态的接口 同步接口服务器负载状态的接口。
	 * 
	 * @return
	 * @throws ITVException
	 */
	public String syncIssStatus(String name, String serverIp, String serviceUrl, String serviceSSLUrl, int count) throws ITVException {
		list.clear();
		list.add(new BasicNameValuePair(HttpKeys.KEY_METHOD, "iss.syncStatus"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_TIMESTAMP_LOWER, "" + System.currentTimeMillis()));
		list.add(new BasicNameValuePair(HttpKeys.KEY_APPKEY, "appkey"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_VERSION, "1.0"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_FORMAT, "json"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SIG, "sig"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SESSIONKEY, ConfigUtil.SessionKey));
		list.add(new BasicNameValuePair(HttpKeys.KEY_NAME, name));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SERVERIP, serverIp));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SERVICEURL, serviceUrl));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SERVICESSLURL, serviceSSLUrl));
		list.add(new BasicNameValuePair(HttpKeys.KEY_COUNT, "" + count));
		return https.get(list);
	}

	/**
	 * 2.30 获取接口服务器服务地址接口 <br>
	 * 应用商城客户端向接口管理服务器发起获取接口服务器地址的请求。<br>
	 * 应用商城客户端使用IPTV的认证参数向接口管理服务器请求。<br>
	 * 这个接口地址可以配置在应用商城客户端。
	 * 
	 * @return
	 * @throws ITVException
	 */
	public String getIssUrl() throws ITVException {
		list.clear();
		list.add(new BasicNameValuePair(HttpKeys.KEY_METHOD, "iss.getUrl"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_TIMESTAMP_LOWER, "" + System.currentTimeMillis()));
		list.add(new BasicNameValuePair(HttpKeys.KEY_APPKEY, "appkey"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_VERSION, "1.0"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_FORMAT, "json"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SIG, "sig"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SESSIONKEY, ConfigUtil.SessionKey));
		list.add(new BasicNameValuePair(HttpKeys.KEY_USERTOKEN_LOWER, ""));
		return https.get(list);
	}

	/**
	 * 2.31 客户端用户上线或者离开接口 应用商城客户端打开应用，最大化应用，最小化应用等事件时，
	 * 需要采用此接口向管理平台发送信息，由管理平台根据这些信号来统计用户的在线时长。
	 * 
	 * @return
	 * @throws ITVException
	 */
	public String userOplog(int opflag) throws ITVException {
		list.clear();
		list.add(new BasicNameValuePair(HttpKeys.KEY_METHOD, "user.oplog"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_TIMESTAMP_LOWER, "" + System.currentTimeMillis()));
		list.add(new BasicNameValuePair(HttpKeys.KEY_APPKEY, "appkey"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_VERSION, "1.0"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_FORMAT, "json"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SIG, "sig"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SESSIONKEY, ConfigUtil.SessionKey));
		list.add(new BasicNameValuePair(HttpKeys.KEY_OPFLAG, "" + opflag));
		return https.get(list);
	}

	/**
	 * 2.35 版本检测接口 应用商城客户端调用该接口实现版本检测功能
	 */
	public String checkUpdate(String appList) throws ITVException {
		list.clear();
		list.add(new BasicNameValuePair(HttpKeys.KEY_METHOD, "app.updateVersion"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_TIMESTAMP_LOWER, "" + System.currentTimeMillis()));
		list.add(new BasicNameValuePair(HttpKeys.KEY_APPKEY, "appkey"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_VERSION, "1.0"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_FORMAT, "json"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SIG, "sig"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SESSIONKEY, ConfigUtil.SessionKey));
		list.add(new BasicNameValuePair(HttpKeys.KEY_MANUFACTURER, Build.MANUFACTURER));
		list.add(new BasicNameValuePair(HttpKeys.KEY_BRAND, Build.BRAND));
		list.add(new BasicNameValuePair(HttpKeys.KEY_MODELID, Build.MODEL));
		list.add(new BasicNameValuePair(HttpKeys.KEY_STBID, Build.ID));
		list.add(new BasicNameValuePair(HttpKeys.KEY_MAC, Util.getMac()));
		list.add(new BasicNameValuePair(HttpKeys.KEY_RELEASE, Build.VERSION.RELEASE));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SDK, Build.VERSION.SDK));
		list.add(new BasicNameValuePair(HttpKeys.KEY_INCREMENTAL, Build.VERSION.INCREMENTAL));
		list.add(new BasicNameValuePair(HttpKeys.KEY_APPLIST, appList));
		return https.get(list);
	}

	/**
	 * 2.36 升级结果上报接口 应用商城客户端调用该接口实现升级结果上报功能
	 */
	public String reportUpdateResult(String UpdateResult) throws ITVException {
		list.clear();
		list.add(new BasicNameValuePair(HttpKeys.KEY_METHOD, "app.reportUpdateResult"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_TIMESTAMP_LOWER, "" + System.currentTimeMillis()));
		list.add(new BasicNameValuePair(HttpKeys.KEY_APPKEY, "appkey"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_VERSION, "1.0"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_FORMAT, "json"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SIG, "sig"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SESSIONKEY, ConfigUtil.SessionKey));
		list.add(new BasicNameValuePair(HttpKeys.KEY_MANUFACTURER, Build.MANUFACTURER));
		list.add(new BasicNameValuePair(HttpKeys.KEY_BRAND, Build.BRAND));
		list.add(new BasicNameValuePair(HttpKeys.KEY_MODELID, Build.MODEL));
		list.add(new BasicNameValuePair(HttpKeys.KEY_STBID, Build.ID));
		list.add(new BasicNameValuePair(HttpKeys.KEY_MAC, Util.getMac()));
		list.add(new BasicNameValuePair(HttpKeys.KEY_RELEASE, Build.VERSION.RELEASE));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SDK, Build.VERSION.SDK));
		list.add(new BasicNameValuePair(HttpKeys.KEY_INCREMENTAL, Build.VERSION.INCREMENTAL));
		list.add(new BasicNameValuePair(HttpKeys.KEY_UPDATERESULT, UpdateResult));
		return https.get(list);
	}

	/**
	 * 版本检测接口 终端管理客户端调用该接口实现版本检测功能
	 */
	public String checkMarketUpdate(String appList) throws ITVException {
		list.clear();
		/**新增升级接口参数  wm start*/
		list.add(new BasicNameValuePair(HttpKeys.KEY_APPKEY, "appkey"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_VERSION, "1.0"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_FORMAT, "json"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SIG, "sig"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_RELEASE, Build.VERSION.RELEASE));
		list.add(new BasicNameValuePair(HttpKeys.KEY_INCREMENTAL, Build.VERSION.INCREMENTAL));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SPID, ConfigUtil.IPTV_SPID));
		list.add(new BasicNameValuePair(HttpKeys.KEY_TRADEID, ""));
		list.add(new BasicNameValuePair(HttpKeys.KEY_USERGROUPNMB, ""));

		String clientId="";
		try {
			if(AppUtils.isPkgExist(context, "com.ihome.android.launcher2")){
				Context  useCount = context.createPackageContext("com.ihome.android.launcher2", Context.CONTEXT_IGNORE_SECURITY);
				SharedPreferences sharePrex = useCount.getSharedPreferences("ottParam", Context.MODE_WORLD_READABLE);
				clientId = sharePrex.getString("clientid", "");
			}
		} catch (NameNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		list.add(new BasicNameValuePair(HttpKeys.KEY_USERID_P, clientId));
		list.add(new BasicNameValuePair(HttpKeys.KEY_AREANO_LOW, SPMgr.getInstance(context).getElement(HttpKeys.KEY_AREANO, "320000")));
		/**新增升级接口参数  wm end*/
		list.add(new BasicNameValuePair(HttpKeys.KEY_MAC_LOWER, Util.getMac()));
		list.add(new BasicNameValuePair(HttpKeys.KEY_MANUFACTURER_LOWER, Build.MANUFACTURER));
		list.add(new BasicNameValuePair(HttpKeys.KEY_BRAND_LOWER, Build.BRAND));
		list.add(new BasicNameValuePair(HttpKeys.KEY_MODEL_LOWER, Build.MODEL));//Build.MODEL
		list.add(new BasicNameValuePair(HttpKeys.KEY_STBID_LOWER, Build.ID));
		list.add(new BasicNameValuePair(HttpKeys.KEY_OSVER, Build.VERSION.SDK));
		list.add(new BasicNameValuePair(HttpKeys.KEY_APPLIST_LOWER, appList));
		return https.get(ConfigUtil.CHECKUPDATE_URL, list);
	}

	/**
	 * 升级结果上报接口 终端管理客户端调用该接口实现升级结果上报功能
	 */
	public String reportMarketUpdateResult(String UpdateResult) throws ITVException {
		list.clear();
		list.add(new BasicNameValuePair(HttpKeys.KEY_USERAPPGROUP, ConfigUtil.USERAPPGROUP));
		list.add(new BasicNameValuePair(HttpKeys.KEY_OTT_CLIENTID, Util.getOTTClientID(context)));
		list.add(new BasicNameValuePair(HttpKeys.KEY_INCREMENTAL, Build.VERSION.INCREMENTAL));
		list.add(new BasicNameValuePair(HttpKeys.KEY_MANUFACTURER_LOWER, Build.MANUFACTURER));
		list.add(new BasicNameValuePair(HttpKeys.KEY_OSVER, Build.VERSION.SDK));
		list.add(new BasicNameValuePair(HttpKeys.KEY_MAC_LOWER, Util.getMac()));
		list.add(new BasicNameValuePair(HttpKeys.KEY_BRAND_LOWER, Build.BRAND));
		list.add(new BasicNameValuePair(HttpKeys.KEY_MODEL_LOWER, Build.MODEL));
		list.add(new BasicNameValuePair(HttpKeys.KEY_STBID_LOWER, Build.ID));
		list.add(new BasicNameValuePair(HttpKeys.KEY_UPDATERESULT_LOWER, UpdateResult));
		list.add(new BasicNameValuePair(HttpKeys.KEY_ERRORDESCRIPTION, ""));
		return https.get(ConfigUtil.UPDATERESULTREPORT_URL, list);
	}

	// ----------------------------------2014-12-19---------------------------------------------
	// ----------------------------------2014-12-19---------------------------------------------
	/**
	 * 4.12 获取欢迎页
	 */
	public String getWelcomeInfo(String areaNo) throws ITVException {
		list.clear();
		list.add(new BasicNameValuePair(HttpKeys.KEY_METHOD, "operation.templateParam"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_TIMESTAMP_LOWER, "" + System.currentTimeMillis()));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SESSIONKEY, ConfigUtil.SessionKey));
		list.add(new BasicNameValuePair(HttpKeys.KEY_AREANO, areaNo));
		list.add(new BasicNameValuePair(HttpKeys.KEY_TEMPLATECODES, "101"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_APPKEY, "appkey"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_VERSION, "1.0"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_FORMAT, "json"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SIG, "sig"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_MAC, Util.getMac()));
		list.add(new BasicNameValuePair(HttpKeys.KEY_BRAND_LOWER, Build.BRAND));
		list.add(new BasicNameValuePair(HttpKeys.KEY_MODEL_LOWER, Build.MODEL));
		list.add(new BasicNameValuePair(HttpKeys.KEY_MANUFACTURER_LOWER, Build.MANUFACTURER));
		return https.get(list);
	}

	/**
	 * 4.14 获取模板的栏目列表 <br>
	 * 
	 */
	public String getTemplateContent(String cacheKey) throws ITVException {
		list.clear();
		list.add(new BasicNameValuePair(HttpKeys.KEY_METHOD, "operation.templateContent"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_TIMESTAMP_LOWER, "" + System.currentTimeMillis()));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SESSIONKEY, ConfigUtil.SessionKey));
		list.add(new BasicNameValuePair(HttpKeys.KEY_CACHEKEY, cacheKey));
		list.add(new BasicNameValuePair(HttpKeys.KEY_APPKEY, "appkey"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_VERSION, "1.0"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_FORMAT, "json"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SIG, "sig"));
		return https.get(list);
	}

	/**
	 * 4.15 获取栏目内容列表 <br>
	 * 
	 */
	public String getSectionContent(String cacheKey, int sectionId) throws ITVException {
		list.clear();
		list.add(new BasicNameValuePair(HttpKeys.KEY_METHOD, "operation.sectionContent"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_TIMESTAMP_LOWER, "" + System.currentTimeMillis()));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SESSIONKEY, ConfigUtil.SessionKey));
		list.add(new BasicNameValuePair(HttpKeys.KEY_CACHEKEY, cacheKey));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SECTIONID, sectionId + ""));
		list.add(new BasicNameValuePair(HttpKeys.KEY_APPKEY, "appkey"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_VERSION, "1.0"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_FORMAT, "json"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SIG, "sig"));
		return https.get(list);
	}
	
	/**
	 * 4.16 获取栏目应用信息列表 <br>
	 * 
	 */
	public String getSectionContentAppList(String cacheKey, int sectionId) throws ITVException {
		list.clear();
		list.add(new BasicNameValuePair(HttpKeys.KEY_METHOD, "operation.appSC"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_TIMESTAMP_LOWER, "" + System.currentTimeMillis()));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SESSIONKEY, ConfigUtil.SessionKey));
		list.add(new BasicNameValuePair(HttpKeys.KEY_CACHEKEY, cacheKey));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SECTIONID, sectionId + ""));
		list.add(new BasicNameValuePair(HttpKeys.KEY_APPKEY, "appkey"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_VERSION, "1.0"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_FORMAT, "json"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SIG, "sig"));
		return https.get(list);
	}
	
	/**
	 * 4.17 获取专题网页链接 <br>
	 * 
	 */
	public String getSpecTopicUrl(int sectionId) throws ITVException {
		list.clear();
		list.add(new BasicNameValuePair(HttpKeys.KEY_METHOD, "operation.specialUrl"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_TIMESTAMP_LOWER, "" + System.currentTimeMillis()));
		list.add(new BasicNameValuePair(HttpKeys.KEY_APPKEY, "appkey"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_VERSION, "1.0"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_FORMAT, "json"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SIG, "sig"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SESSIONKEY, ConfigUtil.SessionKey));
		list.add(new BasicNameValuePair(HttpKeys.KEY_OPTION, "1"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SPECIALID, sectionId + ""));
		return https.get(list);
	}
	
	/**
	 * 文件上传方法
	 * 
	 * @param filePath
	 * @param fileName
	 * @param callback
	 * @throws EAException
	 */
	public boolean fileUpload(String filePath, String fileName) throws ITVException {
		list.clear();
		list.add(new BasicNameValuePair(HttpKeys.KEY_METHOD, "client.dataGather"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_TIMESTAMP_LOWER, "" + System.currentTimeMillis()));
		list.add(new BasicNameValuePair(HttpKeys.KEY_APPKEY, "appkey"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_VERSION, "1.0"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_FORMAT, "json"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SIG, "sig"));
		list.add(new BasicNameValuePair(HttpKeys.KEY_SESSIONKEY, ConfigUtil.SessionKey));
		String url;
		try {
			url = ConfigUtil.SERVER_URL + "?" + Util.encodeUrl(list, true);
			LogUtil.d(TAG, "fileUpload() --> url : " + url);
			//new Upload().filePost(url, filePath, callback);
			return new UploadUtil().uploadFile(url, filePath);
			//https.fileUpload(url, filePath, callback);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}

}
